package ioccontainer;

import parser.ParserTypes;
import testclasses.ClassA;
import testclasses.ClassB;


public class Main {

	public static void main(String[] args) {
		GenericXmlApplicationContext context = new GenericXmlApplicationContext();
		context.setParserType(ParserTypes.StAX);
		try {
		context.load("./xml/beans.xml");		
		BeanFactory factory = context.getBeanFactory();
		Object testObj = factory.getBean("id1");
		System.out.println(testObj);
		System.out.println(((ClassB) testObj).getB());
		ClassB testObj1 = factory.getBean("id2", ClassB.class);
		System.out.println(testObj1.getStr());
		ClassA testObj2 = factory.getBean("id3", ClassA.class);
		System.out.println(testObj2);
		System.out.println(testObj2.getB1());
		System.out.println(testObj2.getB2());
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

}